 var str=""; 
  var strs="";
   str= getvl("chanshu");
   strs=str.split(",");
 var userid=getvl("id");
 
 $(function(){
 	var sun=0;
	if(strs!=''){
		$.each(function(yy,nn){
		  sun++;
	});
	  $("#tuijianshangping").html("推荐商品("+sun+"/30)");
	}else{
		  $("#tuijianshangping").html("推荐商品(0/30)");
	} 
 	weihuofabu(str);
 });


 
  function weihuofabu(str){
    	$("#fabuweihuo").html("");
    	 $.ajax({
      url: urlcore + "/api/goods/selectgoodsAllag?str="+str,
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					var sun=1;
					alert(JSON.stringify(data.data));
					$.each(data.data, function(y,n) {
				var fabuweihuo='<div class="clearfix add_goods">'+
'		<div class="public-xuanze fl" >'+
'			<img src="../images/delete.png" onclick="removeByValues('+n.id+')" width="20" height="20" />'+
'		</div>'+
'		<div class="clearfix tuwen">'+
'	    	<a href="javascript:void(0);">'+
'		        <div class="tuwen-img fl">'+
'		            <img src="'+n.coverUrl+'" width="75" height="75">'+
'		        </div>'+
'		        <div class="tuwen-wenzi">'+
'		            <h5 class="wuye_h01">'+n.goodsTitle+'</h5>'+
'		            <div class="wuye_div02">&yen;'+n.tradePrice+'-&yen;'+n.getPrice+'</div>'+
'		        </div>'+
'	        </a>'+
'	    </div>'+
'	</div>';
                 $("#fabuweihuo").append(fabuweihuo);
                 
					});
				} else if(data.code == 'OVERTIME') {
					var thisUrl = window.location.href;
					alert(thisUrl);
					if(thisUrl.indexOf('1.0.0denglu.html') <= -1) {
						top.window.location.href = "1.0.0denglu.html";
					}
				} else {
					if(data.msg != '空数据') {
						alert(data.msg)
					} else {
						$('#thiscount').text(0);
					}
				}
			},
			error: function() {
				alert("error");
			}
		});	
}
  huoquadmin();
  //获取当前用户
  function huoquadmin(){
	$.ajax({
		url: urlcore + "/api/user/getadmin",
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success:function(data){
			if (data.success == true) {
				
				xiangxi(data.data.id);
			}else{
				window.location.href="../1.0.0denglu.html";
			}
		},
		error:function() {
			/* Act on the event */
			alert("error");
		}
	});	
  }
  
  //查找详细信息
   function xiangxi(sellerId){
	$.ajax({
		url: urlcore + "/api/zbDirectSeeding/selectOne1?sellerId="+sellerId,
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success:function(data){
			if (data.success == true) {
				var da=data.data;
				alert(JSON.stringify(da))
				if(da!=null){			
				$("#imghead1").attr("src",da.imgUrl);
				$("#fengmian").val(da.imgUrl);
				$("#biaoti").val(da.title);
				alert(da.password);
				$("#mima").val(da.password);
				$("#youhuijuan").val(da.packRate);
				$("#kaishi").val(da.startTime);
				$("#jieshu").val(da.endTime);
				alert(JSON.stringify(da.goodsList));
				$.each(da.goodsList,function(y,n){
					
				var fabuweihuo='<div class="clearfix add_goods">'+
'		<div class="public-xuanze fl" >'+
'			<img src="../images/delete.png" onclick="removeByValues('+n.id+')" width="20" height="20" />'+
'		</div>'+
'		<div class="clearfix tuwen">'+
'	    	<a href="javascript:void(0);">'+
'		        <div class="tuwen-img fl">'+
'		            <img src="'+n.coverUrl+'" width="75" height="75">'+
'		        </div>'+
'		        <div class="tuwen-wenzi">'+
'		            <h5 class="wuye_h01">'+n.goodsTitle+'</h5>'+
'		            <div class="wuye_div02">&yen;'+n.tradePrice+'-&yen;'+n.getPrice+'</div>'+
'		        </div>'+
'	        </a>'+
'	    </div>'+
'	</div>';
                 $("#fabuweihuo").append(fabuweihuo);
				});
				$("#kaishizhibo").html("");
	 var anniu='<input type="button" class="p_button" onclick="zhibo()" value="开始私密直播">';
				$("#kaishizhibo").append(anniu);
					}
			}
		},
		error:function() {
			/* Act on the event */
			alert("error");
		}
	});	
  }
  
  
  
  
  
  
  
  

 //提交
   function tijiaos(){
   	if(userid!=''){
   		var fengmian=$("#fengmian").val();
   		var biaoti=$("#biaoti").val();
   		var mima=$("#mima").val();
   		var youhuijuan=$("#youhuijuan").val();
   		var  kaishi=$("#kaishi").html();
   		var jieshu=$("#jieshu").html();
		 $.ajax({
		url: urlcore + "/api/zbDirectSeeding/addPrivate2",
		type: "post",
		contentType: "application/json;charset=utf-8",
		data: JSON.stringify({
	       sellerId:userid,
           imgUrl:fengmian,
           title:biaoti,
           password:mima,
           startTime:kaishi,
           endTime:jieshu,
           goodsIds:str
		}),
		dataType: "json",
		success: function(data) {
			if(data.success == true) {
				alert("申请成功等待审核！");
		     }
		},error: function() {
			alert("error");
		}
	});
	
   	}else{
   		alert("异常");
   	}
   	

   }
   
   
   function zhibo(){
   	   alert("开始直播");
   }
   
   



//删除数组元素
function removeByValues(val) {
	alert(val);
  removeByValue(strs,val);
    strs.toString();
 alert(strs.toString())
  weihuofabu(strs);
}

